package com.cy.pj.common.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class SysLogAspect {
    //定义切入点
    @Pointcut("bean(mailServiceImpl)")
    public void doLogPointCut(){}

    @Around("doLogPointCut()")
    public Object doAround(ProceedingJoinPoint joinPoint)throws Throwable {
        long t1 = System.nanoTime();
        Object result = joinPoint.proceed();
        long t2 = System.nanoTime();
        System.out.println("t2-t1="+(t2-t1));
        return result;
    }
}
